package ru.gerunn.silent.common;

import ru.gerunn.silent.message.Message;


public class RWThread implements Runnable {

	private Reader reader;
	private Writer writer;

	public RWThread(Reader reader, Writer writer) {
		this.setReader(reader);
		this.setWriter(writer);
	}

	public void run() {
		Message message = null;
		try {
			while ((message = this.getReader().read()) != null) {
				this.getWriter().write(message);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private Reader getReader() {
		return reader;
	}

	private void setReader(Reader reader) {
		this.reader = reader;
	}

	private Writer getWriter() {
		return writer;
	}

	private void setWriter(Writer writer) {
		this.writer = writer;
	}

}
